﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NUS.ISS.ARS.Web.PageController;
using NUS.ISS.ARS.Common;
using NUS.ISS.ARS.BusinessEntity;

namespace NUS.ISS.ARS.Web.Booking
{
    public partial class CheckOut : BookingBaseController
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentPage = "CheckOut.aspx";
            base.Page_Load(sender, e);

            if(!IsPostBack)
            {
                btnPre.Visible = IsPrePageVisible;
                btnNext.Visible = IsNextPageVisible;
            }

            pnlMessage.Visible = false;
        }

        protected void btnNext_Click(object sender, EventArgs e)
        {
            MoveToNextPage();
        }

        protected void btnPre_Click(object sender, EventArgs e)
        {
            MoveToPrePage();
        }

        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            SaveResult saveResult = null;

            if (IsManageBooking)
            {
                saveResult = SaveChangedBookings();
            }
            else
            {
                saveResult = SaveSessionToDatabase();
            }
           

           pnlMessage.Visible = true;
           if (saveResult.Status==Constants.SaveStatus.Success)
           {
               pnlMessage.CssClass = "successMessage";
               lblMessage.Text = saveResult.Message;
           }
           else
           {
               pnlMessage.CssClass = "errorMessage";
               lblMessage.Text = saveResult.Message;
           }

           btnCheckOut.Visible = false;
           btnPre.Visible = false;
        }
        
    }
}